home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / AOCE / Development Tools / Sample Code / Standard Catalog Package / AddressOMini / trapavailable.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-28  |  1.3 KB  |  71 lines  |  [TEXT/MPS ]

  1. /*-------------------------------------------------------------------------------------
  2.  *
  3.  * AddressOMini AOCE Sample
  4.  *
  5.  * Steve Falkenburg - MacDTS
  6.  *
  7.  * ©1991-1993 Apple Computer
  8.  *
  9.  -------------------------------------------------------------------------------------*/
  10. /*
  11.  * trapavailable.c -- check to see if a trap is available
  12.  *
  13.  * change history:
  14.  *
  15.  * SJF        2/16/93        1.0b1        beta seed
  16.  *
  17.  */
  18.  
  19. #ifndef __TYPES__
  20. #include <Types.h>
  21. #endif
  22.  
  23. #ifndef __TRAPS__
  24. #include <Traps.h>
  25. #endif
  26.  
  27. #ifndef __OSUTILS__
  28. #include <OSUtils.h>
  29. #endif
  30.  
  31. #ifndef __GESTALTEQU__
  32. #include <GestaltEqu.h>
  33. #endif
  34.  
  35. #include "trapavailable.h"
  36.  
  37. short NumToolboxTraps(void);
  38. TrapType GetTrapType(short theTrap);
  39.     
  40. short NumToolboxTraps(void)
  41. {
  42.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  43.         return 0x0200;
  44.     else
  45.         return 0x0400;
  46. }
  47.  
  48. TrapType GetTrapType(short theTrap)
  49. {
  50.     if ((theTrap & 0x0800) > 0)
  51.         return ToolTrap;
  52.     else
  53.         return OSTrap;
  54. }
  55.  
  56. Boolean    TrapAvailable(short theTrap)
  57. {
  58.     TrapType tType;
  59.     Boolean isAvail;
  60.     
  61.     tType = GetTrapType(theTrap);
  62.     if (tType == ToolTrap)
  63.         {
  64.             theTrap &= 0x07FF;
  65.             if (theTrap >= NumToolboxTraps())
  66.                 theTrap = _Unimplemented;
  67.         }
  68.     
  69.     isAvail = NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap);
  70.     return isAvail;
  71. }